<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>动态绑定 class 属性 ——数组语法</title>
    <style>
        .colordecorate {
            color: red;
        }

        .textdecorate {
            text-decoration: underline;
        }
    </style>
</head>
<body>
<div id="app">
    <h1 class="colordecorate">Hello, World!</h1>
    <!--   对象语法格式：{类名1:true/false, 类名2:true/false,...} -->
    <h1 v-bind:class="{textdecorate: true, colordecorate: true}">Hello, World!</h1>
    <h1 v-bind:class="{textdecorate: isTextDecorated, colordecorate: isColorDecorated}">Hello, World!</h1>

    <!--  将数据对象的定义放到 js 中  -->
    <h1 v-bind:class="isTextDecorated">Hello, World!</h1>
    <h1 v-bind:class="isColorDecorated">Hello, World!</h1>

    <!--  使用多个js 中定义的数据对象，以数据的形式出现  -->
    <h1 v-bind:class="[isTextDecorated, isColorDecorated]">Hello, World!</h1>

    <h1 v-bind:class="all">Hello, World!</h1>
<!--    <h1 v-bind:class="joinAll">Hello, World!</h1>-->

</div>
<script type="module">
    import {createApp, ref, reactive} from "../../../../../js/vue.esm-browser.js";
    const app = createApp({
        setup() {
            let isTextDecorated = ref("textdecorate")
            let isColorDecorated = ref("colordecorate")

            let all = ref("textdecorate colordecorate")
            return {
                isTextDecorated,
                isColorDecorated,

                all,

                // joinAll: this.isColorDecorated + " " + this.isTextDecorated,
            }
        },

        // computed:{
        //     joinAll(){
        //         return this.isColorDecorated + " " + this.isTextDecorated
        //     }
        // }
    })
    app.mount("#app")
</script>
</body>
</html>